import { allMenu } from '../../utils/testData/allMenu';
import { userLogin } from '@/api/user'
import {setStore} from '@/utils/store'
export default {
  state: {
    userInfo: {} || {}, //用户信息
    roles: [],
    token: '',
    refreshRouter: true,
    menuId: [],
    menuList: [
      {
        path: '/index1',
        name: '首页1首页1首页1首页1首页1',
      },
      {
        path: '/RenNing/ceshi',
        name: '首页3',
        children: [
          { path: 'ceshi', name: '首页4' },
          { path: '/index5', name: '首页5' },
        ],
      },
      {
        path: '/RenNing/qwe',
        name: '首页4',
        children: [
          {
            path: '/RenNing/qwe/asd',
            name: 'b',
            children: [{ path: '/RenNing/qwe/asd/zxc', name: 'bc' }],
          },
        ],
      },
      {
        path: '/dev',
        name: '系统设置',
        children: [{ path: '/dev/module/funModDef', name: '功能模块定义' }],
      },
    ],
  },
  actions: {
    //获取AllMenu 全部菜单
    getAllMenu({ state, commit }, payload) {
      return new Promise((resolve, reject) => { });
    },
    /**
     * 处理登录接口
     * @param
     */
    VALID_LOGIN({ commit, state },payload) {
      return new Promise(async (resolve, reject) => {
        let res = await userLogin(payload)
        setStore({name: 'token', content: res.data.token || ''})
        resolve()
      })
    }

  },
  mutations: {
    // VALID_LOGIN(state, payload) {
    //   return new Promise((resolve, reject) => {
    //     state.userInfo = payload.userInfo
    //     resolve()
    //   })
    // }
  },
};
